

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    _utime:number = 0;

    protected onEnable(): void {
        cc.game.on('reset-time',this.resetTime,this);
    } 
    protected onDisable(): void {
        cc.game.off('reset-time',this.resetTime,this);
    }
    
    resetTime(){
        this._utime=0;
    }

    update (dt) {
        let sp=this.node.getComponent(cc.Sprite);
        let material:any= sp.getMaterial(0);
        material.effect.setProperty('u_time',this._utime);
        this._utime+=dt;
    }
}
